package edu.sjb.map.prizes;

import edu.sjb.characters.Mario;
import edu.sjb.threads.SoundThread;

public class JumpingMushroom extends PowerUp {
	public JumpingMushroom() {
		super();
	}

	@Override
	public void run() {
		Mario m = game().mario();
		m.jump();
		while (m.underMushroomEffect()) {
			SoundThread.jump();
			int j = 0;
			while ((j < 21) && m.underMushroomEffect()) {
				m.setPosY(m.posY() - j);
				j++;
				try {
					Thread.sleep(15);
				}
				catch (InterruptedException e) {
				}
			}
			try {
				Thread.sleep(20);
			}
			catch (InterruptedException e) {
			}
			j = 0;
			while ((j < 21) && m.underMushroomEffect()) {
				m.jump();
				if (m.posY() + m.sizeY() == 512) {
					m.setUnderMushroomEffect(false);
				}
				m.setPosY(m.posY() + j);
				j++;
				try {
					Thread.sleep(30);
				}
				catch (InterruptedException e) {
				}
			}
			m.setUnderMushroomEffect(false);
			m.stopLeft();
			m.stopRight();
		}

	}

	@Override
	public void grab() {
	}
}
